Object.defineProperty(n, "__esModule", {
    value: !0
}), n.safeLoadResWithType = function e(t, n, a) {
    var r = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : 0;
    cc.loader.loadRes(t, n, function (s, l) {
        s && r < o ? (r++, setTimeout(function () {
            e(t, n, a, r);
        }, i), console.warn("try reload res: " + t)) : a && a(s, l);
    });
}, n.safeLoadRes = function e(t, n) {
    var a = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 0;
    cc.loader.loadRes(t, function (r, s) {
        r && a < o ? (a++, setTimeout(function () {
            e(t, n, a);
        }, i), console.warn("try reload res: " + t)) : n && n(r, s);
    });
}, n.safeLoad = a;
var o = 6, i = 500;

function a(e, t) {
    var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 0;
    cc.loader.load(e, function (r, s) {
        r && n < o ? (n++, setTimeout(function () {
            a(e, t, n);
        }, i), console.warn("try reload res: " + e)) : t && t(r, s);
    });
}

cc.Director.prototype.safePreloadScene = function (e, t) {
    var n = this._getSceneUuid(e);
    if (n) this.emit(cc.Director.EVENT_BEFORE_SCENE_LOADING, e), a({
        uuid: n.uuid,
        type: "uuid"
    }, function (n, o) {
        n && cc.errorID(1210, e, n.message), t && t(n, o);
    }); else {
        var o = 'Can not preload the scene "' + e + '" because it is not in the build settings.';
        t(new Error(o)), Log.Error("preloadScene: " + o);
    }
}
